package com.ygqh.baby.po;

import com.ygqh.baby.ao.CheckStatus;
import com.ygqh.baby.ao.DataStatus;
import com.ygqh.baby.ao.InviteType;
import com.ygqh.baby.utils.DateConvertUtils;

import java.util.Date;

public class YgAgentInviteRecord {

	private Long id;

	private Long userId;

	private String userName;

	private String inviteCode;

    private InviteType inviteType;

	private Long receiveUserId;

	private String receiveUserName;

	private Date createTime;

	private Date receiveTime;

    private Date expireTime;

	private Date cancelTime;

	private String cancelBy;

    private CheckStatus checkStatus;

	private DataStatus status;

	/*------------------------------*/
	private String nickName;

	public YgAgentInviteRecord() {
		super();
	}

	public YgAgentInviteRecord(Long id, String inviteCode) {
		super();
		this.id = id;
		this.inviteCode = inviteCode;
	}

	public YgAgentInviteRecord(Long userId, String userName, Date createTime) {
		super();
		this.userId = userId;
		this.userName = userName;
		this.createTime = createTime;
	}

	public YgAgentInviteRecord(Long id, Long receiveUserId, String receiveUserName, Date receiveTime, InviteType inviteType, CheckStatus checkStatus, Date expireTime) {
		super();
		this.id = id;
		this.receiveUserId = receiveUserId;
		this.receiveUserName = receiveUserName;
		this.receiveTime = receiveTime;
		this.inviteType = inviteType;
		this.checkStatus = checkStatus;
		this.expireTime = expireTime;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName == null ? null : userName.trim();
	}

	public String getInviteCode() {
		return inviteCode;
	}

	public void setInviteCode(String inviteCode) {
		this.inviteCode = inviteCode == null ? null : inviteCode.trim();
	}

	public Long getReceiveUserId() {
		return receiveUserId;
	}

	public void setReceiveUserId(Long receiveUserId) {
		this.receiveUserId = receiveUserId;
	}

	public String getReceiveUserName() {
		return receiveUserName;
	}

	public void setReceiveUserName(String receiveUserName) {
		this.receiveUserName = receiveUserName == null ? null : receiveUserName.trim();
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getReceiveTime() {
		return receiveTime;
	}

	public void setReceiveTime(Date receiveTime) {
		this.receiveTime = receiveTime;
	}

	public Date getCancelTime() {
		return cancelTime;
	}

	public void setCancelTime(Date cancelTime) {
		this.cancelTime = cancelTime;
	}

	public String getCancelBy() {
		return cancelBy;
	}

	public void setCancelBy(String cancelBy) {
		this.cancelBy = cancelBy == null ? null : cancelBy.trim();
	}

	public DataStatus getStatus() {
		return status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	public boolean inValidTime(Date date) {
		if (receiveTime == null) {
			return false;
		}
		if (receiveTime != null && receiveTime.after(date)) {
			return false;
		}
		if (cancelTime != null && cancelTime.before(date)) {
			return false;
		}
		return true;
	}

	public InviteType getInviteType() {
		return inviteType;
	}

	public void setInviteType(InviteType inviteType) {
		this.inviteType = inviteType;
	}

	public boolean inFreeTime(Date date) {
		if (receiveTime == null || cancelTime != null) {
			return false;
		}
		if (inviteType.equals(InviteType.Ordinary)) {
			Date endDate = DateConvertUtils.getDateEnd(DateConvertUtils.getMonthEndDate(receiveTime)); // 当月不考核
			if (date.before(endDate)) {
				return true;
			}
		}
		if (inviteCode.equals(InviteType.BuySelf)) {
			Date endDate = DateConvertUtils.getMonthEndDate(DateConvertUtils.addYear(receiveTime, 1)); // 一年内不考核
			if (date.before(endDate)) {
				return true;
			}
		}
		return false;
	}

	public Date getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	public CheckStatus getCheckStatus() {
		return checkStatus;
	}

	public void setCheckStatus(CheckStatus checkStatus) {
		this.checkStatus = checkStatus;
	}

	public String getNickName() {
		return nickName;
	}

	public void setNickName(String nickName) {
		this.nickName = nickName;
	}

	@Override
	public String toString() {
		return "YgAgentInviteRecord [id=" + id + ", userId=" + userId + ", userName=" + userName + ", inviteCode=" + inviteCode + ", inviteType=" + inviteType
				+ ", receiveUserId=" + receiveUserId + ", receiveUserName=" + receiveUserName + ", createTime=" + createTime + ", receiveTime=" + receiveTime
				+ ", expireTime=" + expireTime + ", cancelTime=" + cancelTime + ", cancelBy=" + cancelBy + ", checkStatus=" + checkStatus + ", status=" + status
				+ "]";
	}

}